<template>
  <div class="card-wrap paddingAll20">
    <div class="table-title-wrap justify-end">
      <el-button type="primary" size="mini" @click="handleAdd(1)"
                 v-hasPermi="['system:oa:businessAdd']">新增
      </el-button>
    </div>

    <table-page :loading="loading" :dataList="dataList" :total="total" :page.sync="queryParams.pageNum"
                :limit.sync="queryParams.pageSize" @setSizeCurrent="getList" border>
      <!-- 操作插槽 -->
      <template slot="tableColAc">
        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <e-button v-hasPermi="['system:oa:businessDelete']" size="mini" type="text" @click="deleteRow(scope.row)"
            >作废
            </e-button>
            <e-button v-hasPermi="['system:oa:businessAdd']" size="mini" type="text" @click="handleAdd(2,scope.row)"
            >编辑
            </e-button>
          </template>
        </el-table-column>
      </template>
      <!-- 普通列插槽 -->
      <template slot="tableCol">
        <el-table-column label="子类序号" align="center" prop="serialNumber" min-width="120px" show-overflow-tooltip/>
        <el-table-column label="业务类别" align="center" prop="paymentType" min-width="120px" show-overflow-tooltip/>
        <el-table-column label="业务子类" align="center" prop="businessSubclass" min-width="120px" show-overflow-tooltip/>
      </template>
    </table-page>
    <BusinesssubcategoryAdd ref="businesssubcategoryAdd" @success="handleQuery"></BusinesssubcategoryAdd>
  </div>
</template>

<script>
import * as oaApi from "@/api/system/oa";
import BusinesssubcategoryAdd from "@/views/system/oaInfo/components/businessSubcategory/BusinesssubcategoryAdd.vue";
export default {
  components: {BusinesssubcategoryAdd},
  props: {},
  data() {
    return {
      loading:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        type:1
      },
      total: 0,
      dataList: []
    }
  },
  computed: {},
  methods: {
    /** 查询测试单表列表 */
    getList() {
      this.loading = true;
      oaApi.paymentTypeList(this.queryParams).then(res => {
        this.dataList = res.rows;
        this.total = res.total;
      }).finally(() => {
        this.loading = false
      })
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },

    /** 重置按钮操作 */
    resetQuery() {
      this.$nextTick(()=>{
        this.$refs?.queryForm?.resetFields();
        this.handleQuery();
      })
    },

    //新增
    handleAdd(type, row) {
     this.$refs.businesssubcategoryAdd.show(type, row)
    },
    //作废
    deleteRow(row) {
      this.$confirm('此操作将作废该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        oaApi.paymentTypeDelete(row.id).then(res => {
          this.handleQuery()
          this.$message.success('作废成功')
        })
      })
    }
  },
  mounted() {
    this.getList()
  },
}
</script>

<style lang="scss" scoped>
</style>